<!-- 首页 -->
<template>
  <div class="w-full h-full flex flex-col">
    <div class="text-center">总览2</div>
    <div ref="chartBox" class="flex-1"></div>
  </div>
</template>

<script setup name="overview2" lang="ts">
import { onMounted, onUnmounted, reactive, ref } from 'vue'

const { $echarts } = window
const config = reactive({
  data: [],
})

// chart图表
const chartBox = ref()
const chartConfig = reactive({
  chart: null,
  chartBox,
  loopShow: true,
  option: {
    tooltip: {
      trigger: 'item',
    },
    legend: {
      top: '5%',
      left: 'center',
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2,
        },
        label: {
          show: false,
          position: 'center',
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: 'bold',
          },
        },
        labelLine: {
          show: false,
        },
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' },
          { value: 484, name: 'Union Ads' },
          { value: 300, name: 'Video Ads' },
        ],
      },
    ],
  },
})
onMounted(() => {
  chartConfig.chart = $echarts.initChart(chartConfig)
})
onUnmounted(() => {
  $echarts.removeChart(chartConfig)
})
</script>

<style lang="scss" scoped></style>
